<template>
    <div class="e-table">
        <el-table
            ref="history"
            :data="_tableData"
            border
            style="width: 100%"
            @cell-mouse-enter="cellMouseEnter"
            @cell-mouse-leave="cellMouseLeave"
            :cell-class-name="cellClsNm"
            v-sortTable="{ 'tableData': _tableData, '_this': this, 'ref': 'history' }"
            class="table"
        >
            <el-table-column show-overflow-tooltip prop="unitName" label="审核级次" width="150">
            </el-table-column>
            <el-table-column show-overflow-tooltip prop="assignUser" label="审核人" width="120">
            </el-table-column>
            <el-table-column show-overflow-tooltip prop="notifyTime" label="通知时间" width="180">
            </el-table-column>
            <el-table-column show-overflow-tooltip prop="completeTime" label="审核时间" width="180">
            </el-table-column>
            <el-table-column show-overflow-tooltip prop="opinion" label="审核意见" min-width="200">
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import auditRequest from '@/api/subcontractApi/audit.js'

// 组件使用方法
// <ExaHistory
//     :billType="auditParams.billType"
//     :tableData="tableData"
//     @getAuditHistory="getAuditHistory"
// />
// tableData 审核历史数据
// @getAuditHistory 刷新审核历史，用于审核、撤回、作废等等刷新tableData，也可以不传，自己维护tableData

export default {
    props: {
        billType: {
            type: [Number, String],
            required: true
        },
        // 组件传进来的审核历史
        tableData: {
            type: Array,
            default: () => {
                return []
            }
        }
    },
    data () {
        return {
            auditParams: {
                billId: this.$route.query.billid || this.$route.query.tenderId,
                billType: parseInt(this.billType),
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            },
            // 招标的审核历史
            tableData2: []
        }
    },
    computed: {
        _tableData: function () {
            return this.tableData.length !== 0 ? this.tableData : this.tableData2
        }
    },
    created () {
        this.getAuditHistory()
    },
    methods: {
        getAuditHistory () {
            // 如果没传getAuditHistory参数，不传只适合用招标
            if (this.$listeners.getAuditHistory === undefined) {
                auditRequest.getAuditHistory(this.auditParams).then(res => {
                    this.tableData2 = res
                })
            } else {
                this.$emit('getAuditHistory')
            }
        },
        cellMouseEnter () {},
        cellMouseLeave () {},
        cellClsNm () {
            return ''
        }
    }
}
</script>

<style lang="sass" scoped></style>
